package com.whfc.ms.api.fse.controller;

import com.whfc.common.base.BaseController;
import com.whfc.common.result.PageData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.SessionAttr;
import com.whfc.fse.dto.FseCraneRecordDTO;
import com.whfc.fuum.entity.SysUser;
import com.whfc.ms.api.fse.service.MsFseCraneRecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @DESCRIPTION 吊装记录
 * @AUTHOR GuoDong_Sun
 * @DATE 2020/4/9
 */
@RequiresPermissions("fse/crane")
@RestController
@RequestMapping("/ms/api/crane/record")
public class FseCraneRecordController extends BaseController {
    @Autowired
    private MsFseCraneRecordService msFseCraneRecordService;

    @GetMapping("/list")
    public Result list(@SessionAttribute(SessionAttr.MS_USER) SysUser user,
                       @RequestParam("deptId") Integer deptId,
                       @RequestParam("pageNum") Integer pageNum,
                       @RequestParam("pageSize") Integer pageSize,
                       @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam("startTime") Date startTime,
                       @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam("endTime") Date endTime,
                       @RequestParam(value = "keyword", required = false) String keyword) {
        logger.info("吊装记录列表,loginer:{},deptId:{},pageNum:{},pageSize:{},startTime:{},endTime:{},keyword:{}",
                user.getUsername(), deptId, pageNum, pageSize, startTime, endTime, keyword);
        PageData<FseCraneRecordDTO> pageData = msFseCraneRecordService.list(deptId, pageNum, pageSize, startTime, endTime, keyword);
        return ResultUtil.success(pageData);
    }
}
